package com.taoz.rpc.client;

import com.taoz.rpc.common.model.User;
import com.taoz.rpc.common.service.UserService;
import com.taoz.rpc.core.bootstrap.ClientBootstrap;
import com.taoz.rpc.core.config.ApplicationConfig;
import com.taoz.rpc.core.model.ServiceMetaInfo;
import com.taoz.rpc.core.proxy.ServiceProxyFactory;
import com.taoz.rpc.core.registry.Registry;
import com.taoz.rpc.core.registry.RegistryFactory;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

@Slf4j
public class Client {
    public static void main(String[] args) throws InstantiationException, IllegalAccessException {
        ClientBootstrap.init();

        UserService userService = ServiceProxyFactory.getServiceProxy(UserService.class);

//        for (int i = 0; i < 1000; i++) {
//            User user = userService.getUserById(1L);
//            System.out.println(user);
//        }

//        ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
//        executor.scheduleAtFixedRate(() -> {
//            User user = userService.getUserById(1L);
//            System.out.println(user);
//        }, 5, 5, TimeUnit.SECONDS);

        User user = userService.getUserById(1L);
        System.out.println("user = " + user);
    }
}
